package com.team.employment.web.admin.controller.resume;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.team.employment.common.result.Result;
import com.team.employment.model.entity.ResumeInfo;
import com.team.employment.web.admin.custom.check.IdIsEmptyCheck;
import com.team.employment.web.admin.dto.ResumeSearchDto;
import com.team.employment.web.admin.service.ResumeInfoService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "简历查询与搜索")
@RestController
@RequestMapping("/admin/resumeAction")
public class resumeInfoController {
    @Autowired
    private ResumeInfoService resumeInfoService;
    @Autowired
    private IdIsEmptyCheck idIsEmptyCheck;

    @Operation(summary = "分页查询所有简历")
    @GetMapping("pageInfo")
    public Result<IPage<ResumeInfo>> pageInfo(@RequestParam long current, @RequestParam long size){
        IPage<ResumeInfo> page = new Page<>(current,size);
        IPage<ResumeInfo> resultPage = resumeInfoService.page(page);
        return Result.ok(resultPage);
    }

    @Operation(summary = "根据不同条件模糊分页查询简历")
    @PostMapping("pageQueryInfo")
    public Result<IPage<ResumeInfo>> pageQueryInfo(@RequestParam long current, @RequestParam long size, @RequestBody ResumeSearchDto resumeSearchDto){
        IPage<ResumeInfo> page = new Page<>(current,size);
        IPage<ResumeInfo> list = resumeInfoService.pageQueryInfo(page,resumeSearchDto);
        return Result.ok(list);
    }

    @Operation(summary = "根据resume_id删除简历信息")
    @DeleteMapping("removeResumeById/{id}")
    public Result removeResumeById(@PathVariable Long id){
        idIsEmptyCheck.idIsEmpty(resumeInfoService,id);
        resumeInfoService.removeById(id);
        return Result.ok();
    }
}
